<%@include file="/commons/decelerations.jsp"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Modify Roles</title>
   </head>
   <body>   
      <table border="3">
         <tr>
            <td colspan="3">
               <form action="ModifyRole" method="post">
         Role Name : <input type="text" name="delete_role" id="delete_role" size="10"/>
                     <input type="hidden" name="action" value="add" checked/>
                     <input type="submit" value="Add"/>
               </form>
            </td>
         </tr>
         <tr>
            <th>&nbsp;&nbsp;ROLE_NAME&nbsp;&nbsp;</th>
            <th>&nbsp;&nbsp;ACTION&nbsp;&nbsp;</th>
         </tr>
         <c:forEach var="role" items="${requestScope.roleList}" varStatus="roleStatus">
            <tr>
               <td>
                  <c:choose>
                     <c:when test="${param.index == roleStatus.index}">
                        <div>
                           <form action="ModifyRole" method="post">
                              <input type="text" size="10" name="modify_role" id="modify_role" value="${role}"/>
                              <input type="hidden" name="old_rolename" id="old_rolename" value="${role}"/>
                              <input type="hidden" name="action" id="action" value="modify"/>
                              <input type="submit" value="Modify"/>
                           </form>
                        </div>
                     </c:when>
                     <c:otherwise>
                        ${role}
                     </c:otherwise>
                  </c:choose>
               </td>
               <td>
                  Delete&nbsp;
                  <a id="modify_a_tag" href="ModifyRole?action=modify&modify_role=${role}&bogus=true&index=${roleStatus.index}">Modify</a>
               </td>
            </tr>
         </c:forEach>
      </table>

      <p>Total role:&nbsp;
         <c:forEach var="role" items="${roleList}" varStatus="roleStatus">
            ${role}<c:if test="${!roleStatus.last}">,</c:if>
         </c:forEach>
      </p>
      
      <a href="ListPerson">Go to list of persons</a><br/><br/>
      
      <table border="3"><caption><b>Total Person Data</b></caption>
         <tr>
            <th>PERSON_ID</th>
            <th>ROLE_NAME</th>
         </tr>
         <c:forEach var="person" items="${requestScope.personList}">
            <tr>
               <td>${person.personId}</td>
               <td>
                  <c:forEach var="role" items="${person.roles}" varStatus="roleStatus">
                     ${role.roleName}<c:if test="${!roleStatus.last}">,</c:if>
                  </c:forEach>
               </td>
            </tr>
         </c:forEach>
      </table>
      <script src="/scripts/moveDiv.js"></script>
   </body>
</html>